<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>靓号详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/web/res/css/xadmin.css">
    <script src="/web/res/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/web/res/js/xadmin.js"></script>
</head>

<body style="background-color: white;padding:20px;">
<form  class="layui-form layui-form-pane" >
    <div class="layui-form-item">
        <label class="layui-form-label">上传靓号</label>
        <div class="layui-input-inline">
            <input type="text" id="excelname" required  lay-verify="required" placeholder="请上传后缀为.xlsx的Excel文件"  autocomplete="off" class="layui-input">
        </div>
        <button type="button" class="layui-btn layui-btn-sm" id="test3"><i class="layui-icon"></i>上传</button>
    </div>
</form>
<form class="layui-form layui-form-pane"  id="formsubmit" action="/after/user/updatelinghao">
    <div class="layui-form-item">
        <label class="layui-form-label">用户靓号</label>
        <div class="layui-input-block"><input id="id" name="id" hidden value="${id}" />
            <input type="text" id="lianghao" name="lianghao"  value="${(lianghao)!''}" required  lay-verify="required"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">选号区</label>
        <div class="layui-input-block">
            <#list list as user>
                <input type="radio"  name="hao" value="${(user.lianghao)!''}"  title="${(user.lianghao)!''}" <#if user.status?exists && (user.status)?number == 1>disabled</#if> >
            </#list>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" class="layui-btn layui-btn-radius" lay-submit lay-filter="save" >&emsp;保存&emsp;</button>
            <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" onclick="xadmin.close()">&emsp;返回&emsp;</button>
        </div>
    </div>
</form>

<script>
    layui.use(['form','upload'], function(){
        var $ = layui.$;
        var form = layui.form;
        var upload = layui.upload;
        form.render();

        //上传文件
        upload.render({
            elem: '#test3'
            , url: '/after/user/importHao'
            , accept: 'file'
            , acceptMime: '.xlsx'
            , choose: function (obj) {
                layer.load();
                obj.preview(function (index, file, result) {
                    $('#excelname').val(file.name)
                });
            }
            , done: function (res) {
                layer.closeAll('loading');
                layer.msg('上传成功');
                window.location.reload();
            }
        });



        form.on('radio()', function(data){
            //console.log(data.elem); //得到radio原始DOM对象
            //console.log(data.value); //被点击的radio的value值
            $('#lianghao').val(data.value);
        });

        $.fn.extend({
            serializeObject: function() {
                var obj = {}; //声明一个对象
                $.each(this.serializeArray(), function(index, field) {
                    obj[field.name] = field.value; //通过变量，将属性值，属性一起放到对象中
                })
                return obj;
            }
        });
        form.on('submit('+$("button[lay-submit]:eq(0)").attr("lay-filter")+')', function(data){
            layer.confirm('确认要保存吗？', function (index) {
                ajaxPost($,$('#formsubmit').attr("action"),$('#formsubmit').serializeObject(),function (data) {
                    if (data.code == 1) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
                            xadmin.father_reload();
                        });
                    } else {
                        layer.msg(data.msg, {icon: 2, time: 3000}, function(){
                            xadmin.close();
                        });
                    }
                });
            });
        });




    });
</script>
</body>

</html>